#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

int h[2];
vector<int> v[2], ans[N];

void solve(){
    int n;
    cin >> n;
    cout << "? " << 1 << endl;
    fflush(stdout);
    for (int i = 1; i <= n; i++) {
        int dep;
        cin >> dep;
        if (dep == 1) ans[1].push_back(i);
        if (dep != 0) {
            h[dep & 1]++;
            v[dep & 1].push_back(i);
        }
    }
    int k = 0;
    if (h[0] > h[1]) k = 1;
    for (int i : v[k]) {
        cout << "? " << i << endl;
        fflush(stdout);
        for (int j = 1; j <= n; j++) {
            int dep;
            cin >> dep;
            if (dep == 1) ans[i].push_back(j);
        }
    }
    cout << "!" << endl;
    for (int i = 1; i <= n; i++){
        for (int j : ans[i]){
            if (j != 1) cout << i << " " << j << endl;
        }
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}